<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	window.onload = function  () {
		var oText = document.getElementById('text1');

		oText.onfocus = function  () {
			if (this.value == '请输入内容') {
				this.value = '';
			};
		}

		oText.onblur = function (){
			if (this.value == '') {
				this.value = '请输入内容';
			};
		}
	/*
		obj.focus() 	让元素一开始就获取焦点【没有on】
		obj.blur() 		取消指定元素的焦点
		obj.select()	选择指定元素里面的文本内容，及全选文本
	*/
		oText.focus()

		var oBtn = document.getElementById('btn');
		oBtn.onclick = function (){
			oText.select();
		}
	}
	</script>
</head>
<body>
	<input id="text1" type="text" value="请输入内容" />
	<input id="btn" type="button" value="全选" />
</body>
</html>